﻿using System;
using System.Net;
namespace PssFramework
{

    namespace PSServer
    {
        public class ServerEventArgs : EventArgs
        {
            public ServerEventArgs(string mEventData)
            {
                this.mEventData = mEventData;
            }
            public string mEventData;
        }

        public class Server
        {
            bool mServerRunning;
            public event EventHandler OnServerEvent;
            public Server()
            {
                mServerRunning = false;
            }
            public void StartPSS()
            {
                if (!mServerRunning)
                {
                    mServerRunning = true;
                    if (Config.getInstance().Ip != Config.getInstance().HostIp)
                    {
                        Utils.updateHostIpInConfig(Config.getInstance().HostIp);
                    }

                    SubscriberService mSubscriberService = new SubscriberService();
                    mSubscriberService.StartSubscriberService(OnServerEvent);
                    PublisherService mPublisherService = new PublisherService();
                    mPublisherService.StartPublisherService(OnServerEvent);
                }
            }
        }
    }
}